﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cn.Edwon.Web.Support;
using System.Xml;
using System.Reflection;
using Cn.Edwon.Web;
using Cn.Cellula.Client;
using Cn.Edwon.Spring;
using Cn.Cellula.Biz.Port;

namespace Cn.Cellula.Website.Admin.Site {
    public partial class ParmsConfig : PageSupport{
        XmlDocument doc = new XmlDocument();
        String cfgFilePath = ClientHelper.RootPath + "web.config";
        protected void Page_Load(object sender, EventArgs e) {
            doc.Load(cfgFilePath);
            if (!Page.IsPostBack) {
                InitForm();
                FillForm();
            }
        }
        void InitForm() {
        }
        void FillForm() {
            this.txt_TodoRefItemCk.Text = ClientBiz.GetAppItem(ref doc,AppSettingsKey.TodoRefItemCategoryKey);
        }
        protected void btn_save_Click(object sender, EventArgs e) {
            try {
                ClientBiz.SetAppItem(ref doc,AppSettingsKey.TodoRefItemCategoryKey, this.txt_TodoRefItemCk.Text);
                doc.Save(cfgFilePath);
                BizFactory.Get<ILogBiz>().Info("进行了系统参数设置操作", this.Actor, Request);
                SiteInfo.SendSucceed(Page, "");
            } catch (Exception ex) {
                log.Error(ex.Message);
                SiteInfo.Send(Page,TxtDef.ERROR,"保存配置项时出现错误，保存失败");
            }
        }
    }
}